local S = minetest.get_translator("default")


local function firstToUpper(str)
    return (str:gsub("^%l", string.upper))
end
for _,metal in pairs(batteries.metalingots) do
    local metalname = firstToUpper(metal)

    minetest.register_craftitem("technic_batteries:"..metal.."_ingot", {
        description = S(metalname.." ingot"),
        inventory_image = "batteries_"..metal.."_ingot.png",
    })

    minetest.register_craftitem("technic_batteries:"..metal.."_dust", {
        description = S(metalname.." Dust"),
        inventory_image = "batteries_"..metal.."_dust.png",
    })
    
    minetest.register_craftitem("technic_batteries:"..metal.."_lump", {
        description = S(metalname.." Lump"),
        inventory_image = "batteries_"..metal.."_lump.png",
    })

end

if minetest.get_modpath("technic_farming") == nil then

    for _,fruit in pairs(batteries.fruits) do
        minetest.register_node("technic_batteries:bucket_must_"..fruit[1],{
            description = S("Bucket of "..fruit[2].." must"),
            inventory_image = 'bucket.png^(batteries_bucket_contents.png^[colorize:'..fruit[3]..':200)',
            wield_image = 'bucket.png^(batteries_bucket_contents.png^[colorize:'..fruit[3]..':200)',
            tiles = {'bucket.png^(batteries_bucket_contents.png^[colorize:'..fruit[3]..':200)'},
            paramtype = "light",
            is_ground_content = false,
            walkable = false,
            groups = {vessel=1,dig_immediate=3,attached_node=1, must = 1},
            })

        minetest.register_node("technic_batteries:bucket_vinegar_"..fruit[1],{
            description = S("Bucket of "..fruit[2].." vinegar"),
            inventory_image = 'bucket.png^(batteries_bucket_contents.png^[colorize:'..fruit[3]..':100)',
            wield_image = 'bucket.png^(batteries_bucket_contents.png^[colorize:'..fruit[3]..':100)',
            tiles = {'bucket.png^(batteries_bucket_contents.png^[colorize:'..fruit[3]..':100)'},
            paramtype = "light",
            is_ground_content = false,
            walkable = false,
            groups = {vessel=1,dig_immediate=3,attached_node=1, vinegar = 1},
            })
        minetest.register_node("technic_batteries:bottle_must_"..fruit[1],{
            description = S("Bottle of "..fruit[2].." must"),
            inventory_image = 'batteries_bottle_contents.png^[colorize:'..fruit[3]..':200',
            wield_image = 'batteries_bottle_contents.png^[colorize:'..fruit[3]..':200',
            tiles = {'batteries_bottle_contents.png^[colorize:'..fruit[3]..':200'},
            paramtype = "light",
            is_ground_content = false,
            walkable = false,
            groups = {vessel=1,dig_immediate=3,attached_node=1, must = 1},
            })
        minetest.register_node("technic_batteries:glass_must_"..fruit[1],{
            description = S("Glass of "..fruit[2].." must"),
            inventory_image = 'batteries_glass_contents.png^[colorize:'..fruit[3]..':200',
            wield_image = 'batteries_glass_contents.png^[colorize:'..fruit[3]..':200',
            tiles = {'batteries_glass_contents.png^[colorize:'..fruit[3]..':200'},
            paramtype = "light",
            is_ground_content = false,
            walkable = false,
            groups = {vessel=1,dig_immediate=3,attached_node=1, must = 1},
            })
            
    end

end
